﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace rssappbar
{
    /// <summary>
    /// Interaction logic for SettingsWindow.xaml
    /// </summary>
    public partial class SettingsWindow : Window
    {
        public SettingsWindow()
        {
            InitializeComponent();
            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ShowLastVal.Text = Convert.ToString(Properties.Settings.Default.ShowDays);
        }

        private void ButtonSpinner_Spin(object sender, Microsoft.Windows.Controls.SpinEventArgs e)
        {
            Microsoft.Windows.Controls.ButtonSpinner spinner = (Microsoft.Windows.Controls.ButtonSpinner)sender;
            TextBox txtBox = (TextBox)spinner.Content;

            int value = String.IsNullOrEmpty(txtBox.Text) ? 0 : Convert.ToInt32(txtBox.Text);
            if (e.Direction == Microsoft.Windows.Controls.SpinDirection.Increase)
                value++;
            else
                if (value == 1)
                    value = 1;
                else
                    value--;
            txtBox.Text = value.ToString();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.ShowDays = Convert.ToInt32(ShowLastVal.Text);
            Properties.Settings.Default.Save();
            this.Close();
        }

    }
}
